﻿Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Collections.Generic
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Imports System.Data.Common

Public Class globalClass
    Private Shared el As New errorLog

    Public Shared Function Exist(ByVal sProc As String, ByVal sDataColumn As String, ByVal sParameter As String) As Boolean
        Dim _blExist As Boolean = False
        Dim db As Database = DbStoreFactory.CreateDatabase
        Dim cmd As DbCommand = DirectCast(Nothing, DbCommand)

        Try
            cmd = db.GetStoredProcCommand(sProc)
            db.DiscoverParameters(cmd)
            cmd.Parameters(sParameter.ToString).Value = sDataColumn

            _blExist = Convert.ToBoolean(db.ExecuteScalar(cmd))
        Catch ex As DataException
            el.CatchError(ex)
        Finally
            If Not (cmd Is Nothing) Then
                cmd.Dispose()
            End If
        End Try

        Return _blExist
    End Function
    Public Shared Function Exist(ByVal sProc As String, ByVal sDataColumn As Integer, ByVal sParameter As String) As Boolean
        Dim _blExist As Boolean = False
        Dim db As Database = DbStoreFactory.CreateDatabase
        Dim cmd As DbCommand = DirectCast(Nothing, DbCommand)

        Try
            cmd = db.GetStoredProcCommand(sProc)
            db.DiscoverParameters(cmd)
            cmd.Parameters(sParameter.ToString).Value = sDataColumn

            _blExist = Convert.ToBoolean(db.ExecuteScalar(cmd))
        Catch ex As DataException
            el.CatchError(ex)
        Finally
            If Not (cmd Is Nothing) Then
                cmd.Dispose()
            End If
        End Try

        Return _blExist
    End Function
End Class
